Add controls for verify_sub
option in PyJWT
#562
Merged
+51
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses the discussion in this issue: #561
For people who have historically been using values for the
sub
claim other than strings, they may need or want the ability to control PyJWT's new behavior (as of 2.10.0) which is to reject those tokens as invalid.This work adds a new option
JWT_VERIFY_SUB
which can be used to control theverify_sub
option when callingjwt.decode(...)
from the PyJWT library.The default value for
JWT_VERIFY_SUB
isTrue
, which results in thesub
claim being verified. This default results in no change to how the library behaved prior to this addition. By choosing to setJWT_VERIFY_SUB
toFalse
, the user can turn off theverify_sub
option in thejwt.decode
call.I welcome feedback on the naming or anything else regarding the implementation. Also, please let me know if I missed any places where this needs to be tested or documented. Thanks!